package com.timerecording.common.constant;

import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Interner;
import com.google.common.collect.Interners;

import java.math.BigDecimal;
import java.util.*;

/**
 * @author smz41
 * @description: TODO
 * @date 2023/6/23
 */
public class CommonConst {
    /**
     * 全局通用分隔符
     */
    public static final String SEPARATOR = ",";

    /**
     * 全局通用分隔符 逗号
     */
    public static final Character SEPARATOR_CHAR = ',';

    /**
     * 全局通用 冒号
     */
    public static final String COLON = ":";

    /**
     * 全局通用分隔符 斜杠
     */
    public static final String SEPARATOR_SLASH = "/";

    /**
     * 空字符串
     */
    public static final String EMPTY_STR = "";

    /**
     * 空MaP
     */
    public static final Map EMPTY_MAP = Collections.unmodifiableMap(new HashMap<>(0));

    /**
     * 空 list
     */
    public static final List EMPTY_LIST = Collections.unmodifiableList(new ArrayList<>(0));

    /**
     * 默认重置密码
     */
    public static final String RESET_PASSWORD = "123456";

    /**
     * 打卡督学默认推广链接前缀
     */
    public static final String PROMOTION_PREFIX = "/pages/activity/index?activityDaKaId=";

    /**
     * 免费领取资料默认推广链接前缀
     */
    public static final String FREE_MEANS_PREFIX = "/pages/activity/index?meansId=";

    /**
     * 考点速记默认推广链接前缀
     */
    public static final String POINT_PREFIX = "/pages/activity/index?pointId=";


    /**
     * 考点速记默认推广链接前缀
     */
    public static final String QU_DAO_INDEX = "pages/course/index";

    /**
     * 获取小程序二维码查询参数
     */
    public static final String PROMOTION_SCENE = "a=";

    /**
     * 获取代理商端小程序二维码查询参数
     */
    public static final String AGENT_PROMOTION_SCENE = "a=%s&employeeId=%s";

    /**
     * 空字符串
     */
    public static final long DEFAULT_PARENT_ID = 0L;

    public static final class Number {

        public static final int ZERO = 0;

        public static final int ONE = 1;

        public static final BigDecimal ONE_HUNDRED_DECIMAL = new BigDecimal("100");

    }

    /**
     * salt
     */
    public static final String SALT = "zkdx";

    public static final class Token {

        public static final String DEFAULT_TOKEN = "default-token-id-";

        public static final String INNER_TOKEN_NAME = "inner-token";

        public static final String OUTER_TOKEN_NAME = "x-access-token";
    }


    public static final class FileFolderConst {

        /**
         * 公用读取文件夹 public
         */
        public static final String FOLDER_PUBLIC = "pu";

        /**
         * 私有读取文件夹 private
         */
        public static final String FOLDER_PRIVATE = "pr";

        /**
         * 文件夹格式
         */
        public static final String FOLDER_FORMAT = "folder";

    }

    public static final class System {
        /**
         * 系统 id
         */
        public static final Long SYSTEM_ID = 0L;
        /**
         * 系统 名称
         */
        public static final String SYSTEM_NAME = "人民医学网";
        /**
         * oss url redis 过期时间
         */
        public static final int FILE_URL_EXPIRE_SECOND = 3600;

        public static final int FILE_VO_EXPIRE_SECOND = 86400;

        public static final String SA_DEFAULT_TOKEN = "cloud-default-token";

        public static final long ID = 0L;

        public static final String NAME = "系统";

    }

    /**
     * 长度类常量
     */
    public static final class NumberLimit {

        /**
         * 文件名称长度
         */
        public static final int FILE_NAME = 100;

        public static final int USER_NICKNAME = 15;

        /**
         * 最大导出数据天数
         */
        public static final int MAX_EXPORT_DAYS = 180;

    }

    public static final class ApiUrl {
        /**
         * 基础 api 前缀
         */
        public static final String API_PREFIX_BASE = "/base";

        /**
         * 后管 api 前缀
         */
        public static final String API_PREFIX_ADMIN = "/admin";

        /**
         * 通用 api 前缀
         */
        public static final String API_PREFIX_COMMON = "/common";

        /**
         * app 业务 api 前缀
         */
        public static final String API_PREFIX_APP = "/app";

        /**
         * PGC 业务 api 前缀
         */
        public static final String API_PREFIX_PGC = "/pgc";

        /**
         * PGC 业务 api 前缀
         */
        public static final String API_PREFIX_PGC_OPEN_API = "/pgc-open-api";

        /**
         * AGENT 后管 api 前缀
         */
        public static final String API_PREFIX_AGENT = "/agent";


        /**
         * USER api 前缀
         */
        public static final String API_PREFIX_USERS = "/users";

        /**
         * EMPLOYEE api 前缀
         */
        public static final String API_PREFIX_EMPLOYEE = "/employee";

        /**
         * GOODS api 前缀
         */
        public static final String API_PREFIX_GOODS = "/goods";


        /**
         * 工时记录系统  api 前缀
         */
        public static final String API_RECORD_SYSTEM = "/record";

        /**
         * 新版工时记录系统  api 前缀
         */
        public static final String API_NEW_RECORD_SYSTEM = "/new-record";


        /**
         * 登录api接口
         */
        public static final String API_LOGIN = "/login";

    }

    public static final class Password {

        public static final String DEFAULT = "123456";

    }

    public static final class CommonCollection {

        public static final Set<String> IGNORE_URL = ImmutableSet.of("/swagger", "Excel", "/h5/api");

        public static Boolean contain(Set<String> ignores, String uri) {
            if (CollectionUtils.isEmpty(ignores)) {
                return false;
            }
            for (String ignoreUrl : ignores) {
                if (uri.startsWith(ignoreUrl)) {
                    return true;
                }
            }
            return false;
        }
    }

    public static final Interner<String> STRING_POOL = Interners.newWeakInterner();

    /**
     * 终端应用类型
     */
    public static class TerminalApp {

        /**
         * 用户端 - 职考大学 微信小程序
         */
        public static final Integer MP = 100;

        /**
         * 用户端 - 职考大学 H5
         */
        public static final Integer H5 = 101;

        /**
         * 用户端 - 职考大学 H5
         */
        public static final Integer APP = 102;

        /**
         * PGC PC管理端
         */
        public static final Integer PGC_MANAGER_PC = 200;

        /**
         * PC官网 职考大学
         */
        public static final Integer PC = 201;

        /**
         * agent PC管理端
         */
        public static final Integer AGENT_MANAGER_PC = 202;


        /**
         * 护士机考模拟小程序
         */
        public static final Integer MP_HU_SHI_EXAM = 205;


        /**
         * 医师机考模拟小程序
         */
        public static final Integer MP_YI_SHI_EXAM = 210;


        /**
         * 领取资料小程序
         */
        public static final Integer MP_RECEIVE_MATERIAL = 215;

        /**
         * 考点速记小程序
         */
        public static final Integer MP_EXAM_POINT = 220;

        /**
         * 打卡小程序
         */
        public static final Integer MP_DA_KA = 225;

        /**
         * 成考模拟小程序
         */
        public static final Integer MP_ADULT_EXAM = 230;


        /**
         * OPEN_API
         */
        public static final Integer OPEN_API = 300;

    }

    /**
     * 终端应用类型
     */
    public static class UserType {

        /**
         * 职考大学 - 用户
         */
        public static final Integer USER = 1;

        /**
         * PGC管理端 用户
         */
        public static final Integer PGC_MANAGER = 2;

        /**
         * 职考大学 代理商
         */
        public static final Integer AGENT = 21;

        /**
         * 职考大学 管理端 用户
         */
        public static final Integer ADMIN = 3;

        /**
         * 职考大学 系统
         */
        public static final Integer SYSTEM = 4;
    }

    public static class Business {

        /**
         * 默认评价内容
         */
        public static final String DEFAULT_EVALUATE_CONTENT = "买家有点懒，什么都没写~";

    }

    public static class Header {

        public static final String COMPANY = "company";

        public static final String COMPANY_INVITATION_CODE = "companyInvitationCode";

        public static final String AGENT = "user-agent";

        /**
         * 用户唯一标识
         */
        public static final String USER_IDENTITY = "user-identity";

        /**
         * 经纬度
         */
        public static final String USER_GEO = "user-geo";

        /**
         * 位置
         */
        public static final String USER_LOCATION = "user-location";

    }
}
